#include<bits/stdc++.h>
using namespace std;
//int arr[100001];
#define ll long long
int main()
{
	ll N, M;
	cin >> N >> M;// WA 忘记输入
	vector<int> arr(N);
	for (int i = 0; i < N; i++) {// 输入
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());//WA 没有排序
	ll left  = 1;
	ll right = arr[N - 1];
	ll res = 0;
	while (left <= right) {// 二分查找
		ll mid = left + (right - left) / 2;
		ll count = 0;
		for (int i = 0; i < N; i++) {
			if (mid <= arr[i]) count += arr[i] - mid; // WA 忘记判断 出现负数
//			else continue;// 看错变量 和 mid 比较哦
		}
		if (count >= M) {
			res = max(res, mid); // 更新
			left = mid + 1;
		} else {
			right  = mid - 1;
		}
	}
	cout << res << endl;
	return 0;
}
